package com.healthdata.controller;

import com.healthdata.entity.HospitalKind;
import com.healthdata.service.HospitalKindService;
import com.healthdata.service.MedicalInstitutionService;
import com.healthdata.vo.HospitalKindVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/medical")
public class MedicalInstitutionController {

    @Autowired
    private MedicalInstitutionService medicalInstitutionService;

    @Autowired
    private HospitalKindService hospitalKindService;

    @GetMapping("/data")
    public ResponseEntity<Map<String, Object>> getMedicalData() {
        Map<String, Object> response = new HashMap<>();

        response.put("data",medicalInstitutionService.getMedicalData());

        return ResponseEntity.status(HttpStatus.OK).body(response);
    }

    @GetMapping("/kind")
    public ResponseEntity<Map<String,Object>> getKind(@RequestParam String region){
        Map<String, Object> response = new HashMap<>();
        HospitalKindVO hospitalKindVO2011 = hospitalKindService.getFiveYearsHospitalData(region, 2011);
        response.put("data2011", hospitalKindVO2011.getSource());

        HospitalKindVO hospitalKindVO2016 = hospitalKindService.getFiveYearsHospitalData(region, 2016);
        response.put("data2016", hospitalKindVO2016.getSource());
        return ResponseEntity.status(HttpStatus.OK).body(response);
    }
}
